<%@page contentType="text/html" pageEncoding="UTF-8" import="java.io.*, java.sql.*, javax.sql.*, java.math.*"%>
<%!
public String toHex(String arg) throws Exception {
   return new sun.misc.BASE64Encoder().encode(arg.getBytes("UTF-8")).hashCode()+"";

    //return (new java.util.Random())+"";
}

%>
<%

    Connection con = com.elookinto.wordlist.Util.getCon();
    String listName = request.getParameter("listName");
    String uid = (String) session.getAttribute("uid");
    if (listName == null) {
        listName = "%";
    }
    if (uid == null || listName.startsWith("Grade")) {
        uid = "admin";
    }
    int days = 0;
    try {
        days = Integer.parseInt(listName);
    } catch (Exception e) {
    }

    PreparedStatement st = null;
    String note = null;
    st = con.prepareStatement("Select txt from note where listname=? and uid=?");
    st.setString(1, listName);
    st.setString(2, uid);
    ResultSet rs = st.executeQuery();
    if (rs.next()) {
        note = (rs.getString(1));
    }
    if (days == 0) {
        out.println("<B>List:</B> " + listName + "<br/>");
    } else {
        out.println("<B>New Words in Past " + days + " Days</B><br/>");
    }
    if (note != null && note.trim().length() != 0) {
        out.println("<B>Note: </B>" + note + "<hr/>");
    }
    out.println(" <button onclick='hideAll()'>Hide All Openned Dictionaries</button> <br/>");
    if (days == 0) {
        st = con.prepareStatement("Select distinct word, listname  from wordlist where listname=? and uid=?");
        st.setString(1, listName);
        st.setString(2, uid);
    } else {
         st = con.prepareStatement("Select distinct word from wordlist where uid=? and insert_time > sysdate() - ? day");
        st.setString(1, uid);
        st.setInt(2, days);
    }

    rs = st.executeQuery();
    while (rs.next()) {
        String word = rs.getString("word");
        //Character c = C
        //System.out.println(rs.getDate("insert_time"));
        //System.out.println(rs.getString("listname"));
        //System.out.println(rs.getString("uid"));
        //System.out.println(word);
        if (days == 0) {
%>

<button style="color:red" onclick='del("<%= word %>", "<%= listName%>")'> X </button>  
<%}%>
<!--   
<img src="http://onelook.com/img/speaker-icon.gif"    onclick="play1('<%=word%>')" /> -->
<a id='b0<%= toHex(word) %>' title="onelook" class="button" href='javascript:void(0)' onclick= "wordClick(this,'<%= word%>', '<%= toHex(word)%>', 0);"><span>Look Up</span></a>
<!--
<a id='b1<%=word%>'  title="WordSmyth Beginner's Dictionary" class="button" href='javascript:void(0)' onclick="wordClick(this,'<%= word%>', 1)"><span>B</span></a>
<a id='b2<%=word%>' title="WordSmyth Children's Dictionary" class="button" href='javascript:void(0)' onclick="wordClick(this,'<%= word%>', 2)"><span>C</span></a>
<a id='b3<%=word%>' title="WordSmyth Advanced Dictionary" class="button" href='javascript:void(0)' onclick="wordClick(this,'<%= word%>', 3)"><span>A</span></a>
-->
<a id='id<%= toHex(word)%>' href='javascript:void(0)' style="text-decoration: none" ><%= word%></a> 
<iframe    width=100% height=1000 style='display:none' id="frame<%= toHex(word)%>"> </iframe> <br/>
<%}
    rs.close();
    st.close();
    con.close();
%>
